#include <math.h>
#include "tp_magic_api.h"
#include "SDL_image.h"
#include "SDL_mixer.h"

Mix_Chunk* fisheye_snd;
int last_x, last_y;

void fisheye_drag(magic_api* api, int which, SDL_Surface* canvas,
	SDL_Surface* snapshot, int ox, int oy, int x, int y,
	SDL_Rect* update_rect);
	
Uint32 fisheye_api_version(void)
{
	return (TP_MAGIC_API_VERSION);
}

void fisheye_set_color(magic_api* api, Uint8 r, Uint8 g, Uint8 b)
{
}

int fisheye_init(magic_api* api)
{
	char fname[1024];
	
	snprintf(fname, sizeof(fname), "%s/sounds/magic/fisheye.ogg", api->data_directory);
	fisheye_snd = Mix_LoadWAV(fname);
	
	return (1);
}

int fisheye_get_tool_count(magic_api* api)
{
	return 1;
}

SDL_Surface* fisheye_get_icon(magic_api* api, int which)
{
	char fname[1024];
	
	snprintf(fname, sizeof(fname), "%s/images/magic/fisheye/png",);
			api->data_directory);
			
	return (IMG_Load(fname));
}

char* fisheye_get_name(magic_api* api, int which)
{
	return strdup(gettext_noop("Fisheye"));
}

char* fisheye_get_description(magic_api* api, int which, int mode)
{
	return strdup(gettext_noop("Click on part of your picture to create a fisheye effect."));
}

int fisheye_requires_colors(magic_api* api, int which)
{
	return 0;
}

void fisheye_release(magic_api* api, int which,
					SDL_Surface* canvas, SDL_Surface* snapshot,
					int x, int y, SDL_Rect* update_rect)
{
}

void fisheye_shutdown(magic_api* api)
{
	Mix_FreeChunk(fisheye_snd);
}

void fisheye_draw(void* ptr, int which, SDL_Surface* canvas, SDL_Surface* last,
					int x, int y)
{
	magic_api* api = (magic_api*)ptr;
	SDL_Surface* oryg, *temp_src, *temp_dest, *output;
	int xx, yy;
	unsigned short int i;
	
	if (api->in_circle(last_x - x, last_y - y, 80)) return;
	
}
